package com.cj.designpattern.strategy.impl;

import com.cj.designpattern.strategy.ICalculateStrategy;

/**
 * ClassName: SubwayStrategy <br/>
 * Function: 地铁计算价格策略 <br/>
 * date: 2018/04/28 14:27 <br/>
 *
 * @author chenj
 * @version 1.0.0
 * @since JDK 1.8
 */
public class SubwayStrategy implements ICalculateStrategy {

    @Override
    public int calculatePrice(int km) {
        int price;
        if (km <= 6) {
            price = 3;
        } else if (km > 6 && km < 12) {
            price = 4;
        } else if (km < 22 && km > 12) {
            price = 5;
        } else if (km < 32 && km > 22) {
            price = 6;
        } else {
            price = 7;
        }
        System.out.println("做地铁" + km + "公里，价格为：" + price + "元");
        return price;
    }
}
